<template>
	<view class="settingBox">
		<view class="itembox">
			<view class="item logo">
				<text>门店LOGO</text>
				<image v-if="data.logo" :src="`${host}${data.logo}`" mode="aspectFill"></image>
			</view>
			<view class="item">
				<text>门店分类</text>
				<text>{{classlist[data.class_id]}}</text>
			</view>
			<view class="item">
				<text>联系人名字</text>
				<text>{{data.fzr_name}}</text>
			</view>
			<view class="item">
				<text>商家名称</text>
				<text>{{data.title}}</text>
			</view>
			<view class="item">
				<text>联系电话</text>
				<text>{{data.phone}}</text>
			</view>
			<view class="item">
				<text>人均消费</text>
				<text>{{data.uniformity}}元</text>
			</view>
			<view class="item">
				<text>详细地址</text>
				<text class="text-overflow">{{data.address}}</text>
			</view>
			<view class="item">
				<text>经营理念</text>
				<text class="linian">{{data.purpose}}</text>
			</view>
			<view class="item" @click="updateSetting">
				<text class="updateMsg" >修改资料</text>
				<text class="iconfontPT iconxiayibu"></text>
			</view>
		</view>
		<view class="itembox">
			<view class="item" @click="updatepassword">
				<text>修改密码</text>
				<text class="iconfontPT iconxiayibu"></text>
			</view>
			<view class="item" @click="loginOut">
				<text>退出登录</text>
				<text class="iconfontPT iconxiayibu"></text>
			</view>
		</view>
	</view>
	
</template>

<script>
	import {
		loginOut,
		editStore
	} from 
	 "../../apis/shop/api.js"
	export default{
		data(){
			return{
				store_id:"",
				token:"",
				data:"",
				classlist:""
			}
		},
		computed:{
			host(){
				return this.$baseHost.car
			}
		},
		onLoad() {
			this.store_id = uni.getStorageSync("store_id");
			this.token = uni.getStorageSync("token");
			this.getData()
		},
		onShow(e) {
			let pages = getCurrentPages();
			let currPage = pages[pages.length - 1]; //当前页面
			let that = this
			if(currPage.data.isDoRefesh){
				currPage.data.isDoRefesh = false
				that.getData()
			}
			
		},
		methods:{
			chekcInfo(){
				location.reload()
			},
			updatepassword(){
				uni.navigateTo({
					url:"/pages/shopmanager/updatepassword?phone="+this.data.phone
				})
			},
			getData(){
				let that = this
				editStore({
					id:that.store_id,
					token:that.token
				}).then(res=>{
					if(res.code == 1){
						that.data = res.data.row;
						that.classlist = res.data.class;
					}
				})
			},
			updateSetting(){
				console.log(1111)
				uni.navigateTo({
					url:"/pages/shopmanager/updatesetting"
				})
			},
			loginOut(){
				let that = this;
				loginOut({
					token:that.token
				}).then(res=>{
					if(res.code == 1){
						uni.removeStorageSync('token');
						uni.removeStorageSync('shopMsg');
						uni.showToast({
							title:"注销成功"
						})
						
						uni.switchTab({
						     url:"/pages/personal"
						})
					}
					})
			}
		}
	}
</script>

<style lang="less">
	.settingBox{
		background-color: #f8f8f8;
	}
	.itembox{
		margin-top:16rpx ;
		background-color: #fff;
		padding: 0 30rpx;
		.item{
			&+.item{
				border-top:1rpx solid #C7BEBE ;
			}
			&::after{
				content: "";
				display: block;
				height: 0;
				overflow: hidden;
				clear: both;
			}
			text{
				line-height: 88rpx;
				&.updateMsg{
					color: #E41805 !important;
				}
				&:nth-child(1){
					font-size: 30rpx;
					color: #333;
					float: left;
				}
				&.linian{
					line-height: 44rpx;
					padding: 22rpx 0;
				}
				&:nth-child(2){
					font-size: 30rpx;
					color: #333;
					float: right;
					max-width: calc(~"100% - 250rpx");
					overflow: hidden;
				}
			}
			image{
				float: right;
				width: 84rpx;
				height: 84rpx;
				border-radius: 84rpx;
			}
		}
	}
</style>
